
<template>
    <div :class="setTypeStyle(typeName)">{{typeName}}</div>
</template>
<script setup>
import {onMounted, ref, watch} from 'vue'
const props = defineProps({ scope: {
  default: ''
} })
const typeName = ref('')
const getTypeName = () => {
  const typeMap = {
    institution: '机构',
    association: '协会',
    enterprise: '企业'
  }
  return typeMap[props.scope.typeCode]
}
function setTypeStyle(typeName) {
  switch (typeName) {
    case '机构': return 'insType';
    case '协会': return 'assType'
  }
}
watch(() => { return props.scope.typeCode }, () => {
  // 数据变化之后的回调函数
  typeName.value = getTypeName()
}, { immediate: true, deep: false })

onMounted(() => {

})
</script>

<style scoped>
.insType {
  position: relative;
  margin: auto;
  width: 46px;
  height: 20px;
  color: #409EFF;
  font-size: 14px;
  padding: 0 8px;
  border: 1px solid #D9ECFF;
  border-radius: 2px;
  background-color: #ECF5FF;
  opacity: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.assType {
  position: relative;
  margin: auto;
  width: 46px;
  height: 20px;
  color: #FF9224;
  padding: 0 8px;
  border: 1px solid #FFE6CE;
  border-radius: 2px;
  background-color: #FFF6EC;
  opacity: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>
